###
 # @Company: TWL
 # @Author: xue jian
 # @Email: xuejian@kanzhun.com
 # @Date: 2020-07-29 16:15:32
### 
train_table=arc_six_dev.bossrec_train

gen_origen_data_file() {
    day=$1
    outpath=/data1/xuejian/sync/offline_train/cp_active_time/$day
    if [ ! -d $outpath ]; then
        mkdir -p ${outpath}
    fi

    # 0~11
    hive -e "set mapreduce.job.queuename=boss.arc.six.vip;
    select boss_city, boss_position, cast(geek_min_active_tdiff as int), cast(exp_min_active_tdiff as int) from $train_table where ds = '${day}' and hour(list_time) >= 0 and hour(list_time) < 12;" > $outpath/boss_exposure_geek_actice_full_time_am

    #12~23
    hive -e "set mapreduce.job.queuename=boss.arc.six.vip;
    select boss_city, boss_position, cast(geek_min_active_tdiff as int), cast(exp_min_active_tdiff as int) from $train_table where ds = '${day}' and hour(list_time) > 11 and hour(list_time) <= 23;" > $outpath/boss_exposure_geek_actice_full_time_pm
}

main() {
    datebeg=$1
    dateend=$2
    beg_s=`date -d "$datebeg" +%s`
    end_s=`date -d "$dateend" +%s`
    while [ "$beg_s" -le "$end_s" ]
    do
        tmp=`date -d @$beg_s +"%Y-%m-%d"`
        echo $tmp
        gen_origen_data_file $tmp
        beg_s=$((beg_s+86400))
    done
}

main 2020-07-22 2020-07-28